var lon, lat, city, timerobj, timer;
mui.init({
	pullRefresh: {
		container: '#pullrefresh',
		down: { //下拉刷新
			callback: pulldownRefresh,
			style: mui.os.android ? "circle" : "default"
		}
	}
});



mui.plusReady(function() {
	storage.init();
	//注册登录事件
	appPage.registerCheckLoginEvent();

	initPage();

//点击进入详情
	mui("#list_wrap").on('tap', 'li', function() {
		var id = this.getAttribute("data-id");
		openNew("equipmentDetail.html", {
			id: id
		});
	})
	//点击搜索
	document.getElementById('search').addEventListener('tap',function(){
		openNew("../widget/search.html");
	})
})

function initPage() {
	lon = storageLocation.Lon;
	lat = storageLocation.Lat;
	city = storageLocation.City;
	//document.getElementById("city").innerText = city;

	loadData();
}
//下拉刷新具体业务实现
function pulldownRefresh() {
	loadData();
}
//一次性拉取数据
function loadData() {
	request("/Index/getIndexLis", {
		lon: lon,
		lat: lat,
		cityid: storageLocation.CityId
	}, function(json) {
		if (json.code == "0") {

		} else {
			appUI.showTopTip(json.msg)
		}
		appPage.endPullRefresh();
	}, false, function() {
		appPage.endPullRefresh();
		var arr = document.getElementsByClassName("nodata");
		for (var i = 0; i < arr.length; i++) {
			arr[i].innerText = "暂无数据";
		}
	});
}
